import React, {Component} from 'react';
import Add from "./Add";
import Sub from "./Sub";

class App extends Component {

    constructor(props) {
        super(props);
        this.state = {
            count: 100
        }
    }

    changCounter(counter) {
        this.setState({count: this.state.count + counter})
    }

    render() {
        return (
            <div>
                <h2>{this.state.count}</h2>
                <Add onChange={(count) => this.changCounter(count)}/>
                <Sub onChange={(count) => this.changCounter(count)}/>
            </div>
        );
    }
}

export default App;